<?php
include_once("ConnectionManager.php");

function findAllNewsletters(){
	$query = "SELECT * FROM MITI_NEWSLETTER";
	ConnectionManager::getInstance()->setQuery($query);
    return ConnectionManager::getInstance()->query();
}

function createNewsletter($email){
	$query = "INSERT INTO MITI_NEWSLETTER (NLE_EMAIL) VALUES ('$email')";
	ConnectionManager::getInstance()->setQuery($query);
    ConnectionManager::getInstance()->query();
	return mysql_affected_rows() > 0;
}

function deleteNewsletter($newsletterId){
	$query = "DELETE FROM MITI_NEWSLETTER WHERE NLE_ID = $newsletterId";
	ConnectionManager::getInstance()->setQuery($query);
    ConnectionManager::getInstance()->query();
	return mysql_affected_rows() > 0;
}

function getTotalSubscriber(){
    $query = "SELECT COUNT(NLE_ID) AS QTY FROM MITI_NEWSLETTER";
    ConnectionManager::getInstance()->setQuery($query);
    $array = ConnectionManager::getInstance()->query();
    $result = mysql_fetch_array($array);
    return $result["QTY"];
}
?>